﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SB;

namespace 养老金支付系统
{
    public partial class FormMain : FormBase
    {
        
        public FormMain()
        {
            InitializeComponent();
        }

        string dfqh;
        int zfhjm;
        string zfhj;

        private void FormMain_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            init();
        }

        void init()
        {
            dfqh = SqlHelper.getScalar("select dbo.GetNowQH()") as string;
            zfhjm = (int)SqlHelper.getScalar("select dbo.GetNowZFHJ()");
            zfhj = SqlHelper.getScalar("select 支付环节 from 支付环节列表 where 支付环节码=dbo.GetNowZFHJ()") as string;
            this.Text = "养老金支付系统 - 当前正在办理 [" + dfqh + "] [" + zfhj + "] 环节";
//#if debug
            switch (zfhjm)
            {
                case 0:
                    toolStripMenuItem1.Enabled = true;
                    toolStripMenuItem2.Enabled = false;
                    toolStripMenuItem3.Enabled = false;
                    break;
                case 1:
                    toolStripMenuItem1.Enabled = false;
                    toolStripMenuItem2.Enabled = true;
                    toolStripMenuItem3.Enabled = false;
                    break;
                case 2:
                    toolStripMenuItem1.Enabled = false;
                    toolStripMenuItem2.Enabled = false;
                    toolStripMenuItem3.Enabled = true;
                    break;
                default:
                    break;
            }
//#endif
        }
        void nexthj()
        {
            string msg = "确定[" + this.dfqh + "]期[" + this.zfhj + "]环节的业务已办理完成，并进入下一支付环节？";
            if (MessageBox.Show(this, msg, "进入下一支付环节", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                if (SqlHelper.exeProcReturn("P_进入下一支付环节") > 0)
                {
                    MessageBox.Show(this, "进入成功！当前支付环节[" + this.zfhj + "]", "进入下一支付环节", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "进入失败！当前支付环节[" + this.zfhj + "]", "进入下一支付环节", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                init();
            }
        }

        void lasthj()
        {
            string msg = "确定删除[" + this.dfqh + "]期[" + this.zfhj + "]环节的所有业务，并返回上一支付环节？";
            if (MessageBox.Show(this, msg, "返回上一支付环节", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                if (SqlHelper.exeProcReturn("P_返回上一支付环节") > 0)
                {
                    MessageBox.Show(this, "返回成功！当前支付环节[" + this.zfhj + "]", "返回上一支付环节", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "返回失败！当前支付环节[" + this.zfhj + "]", "返回上一支付环节", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                init();
            }
        }

        private void nexthj_Click(object sender, EventArgs e)
        {
            nexthj();
        }

        private void lasthj_Click(object sender, EventArgs e)
        {
            lasthj();
        }

        private void Menu_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsm = sender as ToolStripMenuItem;
            Type type = Type.GetType("养老金支付系统.Form" + tsm.Name);
            if (type != null)
            {
                FormBase f = type.Assembly.CreateInstance(type.FullName) as FormBase;
                f.MdiParent = this;
                f.WindowState = FormWindowState.Maximized;
                f.Show();
            }
        }

        private void toolStripMenuItem20_Click(object sender, EventArgs e)
        {
            FormSBBFLR f = new FormSBBFLR() { MdiParent = this, WindowState = FormWindowState.Maximized };
            f.Show();
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            FormYCXZFLR f = new FormYCXZFLR() { MdiParent = this, WindowState = FormWindowState.Maximized };
            f.Show();
        }

    }
}
